﻿#define Framework4

using System;
using System.Reflection;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        class ListEnvironment : MyList
        {
            public ListEnvironment(State MyState)
                : base(MyState, "Environment")
            {
                AddTitle("Framework Version", 2);

                string FrameWorkVersions = "";
                foreach (AssemblyName an in Assembly.GetExecutingAssembly().GetReferencedAssemblies())
                {
                    if (an.Name == "mscorlib")
                        FrameWorkVersions += an.Version.ToString() + "<br/>";
                }
                Add("FrameWorkVersion", FrameWorkVersions);

                string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                Add("User", user);
                // p.Controls.Add(GetData());

                AddTitle("Environment", 2);

                Add("CommandLine", Environment.CommandLine);
                Add("CurrentDirectory", Environment.CurrentDirectory);
                Add("EnvironmentVariables", GetDictionary(Environment.GetEnvironmentVariables()));
                Add("ExitCode", Environment.ExitCode.ToString());
                Add("MachineName", Environment.MachineName);
                Add("NewLine", Hex.ToHex(Environment.NewLine));
                Add("OSVersion", Environment.OSVersion.ToString());
                Add("ProcessorCount", Environment.ProcessorCount.ToString());
                Add("StackTrace", Environment.StackTrace);
                Add("SystemDirectory", Environment.SystemDirectory);
                Add("TickCount", Environment.TickCount.ToString());
                Add("UserDomainName", Environment.UserDomainName);
                Add("UserInteractive", Environment.UserInteractive.ToString());
                Add("UserName", Environment.UserName);
                Add("Version", Environment.Version.ToString());
                Add("WorkingSet", Environment.WorkingSet.ToString());
#if Framework4
                try
                {
                    Add("Is64BitOperatingSystem", Environment.Is64BitOperatingSystem.ToString());
                }
                catch
                {
                    Add("Is64BitOperatingSystem", strRequiresFramework4);
                }
                try
                {
                    Add("Is64BitProcess", Environment.Is64BitProcess.ToString());
                }
                catch
                {
                    Add("Is64BitProcess", strRequiresFramework4);
                }
                try
                {
                    Add("SystemPageSize", Environment.SystemPageSize.ToString());
                }
                catch
                {
                    Add("SystemPageSize", strRequiresFramework4);
                }
#endif
            }
        }
    }
}